import java.util.*;

import static java.lang.String.*;

public class MySort {
	public static void main(String[] args) {
		String[] toSort = {"aaa:10:1:1",
				"ccc:30:3:4",
				"bbb:50:4:5",
				"ddd:20:5:3",
				"eee:40:2:20"};

		System.out.println("Before sort:");
		for (String str : toSort)
			System.out.println(str);

		//sort
		String[] k3 = new String[toSort.length];

		for (int i = 0; i < toSort.length; i++) {

			String tmp[] = toSort[i].split(":");
			System.out.println(tmp[i]);
			}
 
	Arrays.sort(toSort);
	for(int i = 0;i<k3.length;i++)
	for(int j = 0;j<toSort.length;j++) {
		if (k3[i].toCharArray()[0] != toSort[j].charAt(7))
			continue;
		System.out.println(toSort[j]);
	}

	System.out.println("After sort:");
	System.out.println(toSort);
	}
}
